package com.fingersoft.im.feature.aiassistant

import android.app.Activity
import cn.fingersoft.im.dagger2.DaggerAppComponent
import dagger.android.AndroidInjector
import dagger.android.DispatchingAndroidInjector
import dagger.android.HasActivityInjector
import io.dcloud.application.DCloudApplication
import javax.inject.Inject

/**
 * @author：jooper  Email：jooperge@163.com
 * 描述：
 * 修改历史:
 * <p>
 * 创建于： 2020/4/26
 */
open class DaggerApplication : DCloudApplication(), HasActivityInjector {

    override fun activityInjector(): AndroidInjector<Activity> {
        return dispatchingAndroidInjector
    }

    @Inject
    lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Activity>

    override fun onCreate() {
        super.onCreate()

        DaggerAppComponent.builder().application(this).build().inject(this)
        if (!::dispatchingAndroidInjector.isInitialized) {
            throw Exception("dispatchingAndroidInjector is null")
        }
    }
}
